AC_DEFUN([WITH_HARU], [
  AC_MSG_CHECKING(LibHaru install...)

  AC_ARG_WITH(haru, [  --with-haru=PATH path to prefix dir for include LibHaru ], [
  if test -x $withval -a -f $withval
    then
      HARU_PREFIX=$withval
    elif test -e $withval/include/hpdf.h
    then
     HARU_PREFIX=$withval
    fi
  ], [
  if test -e $prefix/include/hpdf.h
    then
      HARU_PREFIX=$prefix
  	elif test -e /usr/local/include/hpdf.h
    then
      HARU_PREFIX=/usr/local
    elif test -e /usr/include/hpdf.h
    then
      HARU_PREFIX=/usr
    fi
  ])
  if test "x$HARU_PREFIX" = "x"
  then
    AC_MSG_RESULT(not found)
    exit 3
  else
    AC_MSG_RESULT(found)
  	AC_PROG_CC
    AC_PROG_CXX

    HARU_CFLAGS="-I$HARU_PREFIX/include "`libpng-config --cflags`" "
    HARU_LIBS="-L$HARU_PREFIX/lib -lz -lhpdf -DHPDF_SHARED -lpng "`libpng-config --ldflags`" -lm -lstdc++"
    
    AC_SUBST([HARU_PREFIX])
    AC_SUBST([HARU_CFLAGS])
    AC_SUBST([HARU_LIBS])
    
  fi
])